package org.zoomdev.zoom.dao.utils;

import java.util.regex.Pattern;

public class SqlUtils {
    private static final Pattern BASIC_PATTERN = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_]*$");

    /**
     * 是否不合法
     *
     * @param name 名称
     * @return true:不合法
     */
    public static boolean isInvalidName(String name) {
        if (name == null) {
            return true;
        }
        return !BASIC_PATTERN.matcher(name).matches();
    }

    public static String escapeSql(String str) {
        if (str == null) return "";
        return str.replace("'", "\\'");
    }
}
